<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.4.1: http://docutils.sourceforge.net/" />
<title>Easypost; A basic CLI postfix/dovecot administration system</title>
<style type="text/css">

/*
:Author: David Goodger
:Contact: goodger@users.sourceforge.net
:Date: $Date: 2005-12-18 01:56:14 +0100 (Sun, 18 Dec 2005) $
:Revision: $Revision: 4224 $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
  border: 0 }

table.borderless td, table.borderless th {
  /* Override padding for "table.docutils td" with "! important".
     The right padding separates the table cells. */
  padding: 0 0.5em 0 0 ! important }

.first {
  /* Override more specific margin styles with "! important". */
  margin-top: 0 ! important }

.last, .with-subtitle {
  margin-bottom: 0 ! important }

.hidden {
  display: none }

a.toc-backref {
  text-decoration: none ;
  color: black }

blockquote.epigraph {
  margin: 2em 5em ; }

dl.docutils dd {
  margin-bottom: 0.5em }

/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
  font-weight: bold }
*/

div.abstract {
  margin: 2em 5em }

div.abstract p.topic-title {
  font-weight: bold ;
  text-align: center }

div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
  margin: 2em ;
  border: medium outset ;
  padding: 1em }

div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
  font-weight: bold ;
  font-family: sans-serif }

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
  color: red ;
  font-weight: bold ;
  font-family: sans-serif }

/* Uncomment (and remove this text!) to get reduced vertical space in
   compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
  margin-bottom: 0.5em }

div.compound .compound-last, div.compound .compound-middle {
  margin-top: 0.5em }
*/

div.dedication {
  margin: 2em 5em ;
  text-align: center ;
  font-style: italic }

div.dedication p.topic-title {
  font-weight: bold ;
  font-style: normal }

div.figure {
  margin-left: 2em ;
  margin-right: 2em }

div.footer, div.header {
  clear: both;
  font-size: smaller }

div.line-block {
  display: block ;
  margin-top: 1em ;
  margin-bottom: 1em }

div.line-block div.line-block {
  margin-top: 0 ;
  margin-bottom: 0 ;
  margin-left: 1.5em }

div.sidebar {
  margin-left: 1em ;
  border: medium outset ;
  padding: 1em ;
  background-color: #ffffee ;
  width: 40% ;
  float: right ;
  clear: right }

div.sidebar p.rubric {
  font-family: sans-serif ;
  font-size: medium }

div.system-messages {
  margin: 5em }

div.system-messages h1 {
  color: red }

div.system-message {
  border: medium outset ;
  padding: 1em }

div.system-message p.system-message-title {
  color: red ;
  font-weight: bold }

div.topic {
  margin: 2em }

h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
  margin-top: 0.4em }

h1.title {
  text-align: center }

h2.subtitle {
  text-align: center }

hr.docutils {
  width: 75% }

img.align-left {
  clear: left }

img.align-right {
  clear: right }

ol.simple, ul.simple {
  margin-bottom: 1em }

ol.arabic {
  list-style: decimal }

ol.loweralpha {
  list-style: lower-alpha }

ol.upperalpha {
  list-style: upper-alpha }

ol.lowerroman {
  list-style: lower-roman }

ol.upperroman {
  list-style: upper-roman }

p.attribution {
  text-align: right ;
  margin-left: 50% }

p.caption {
  font-style: italic }

p.credits {
  font-style: italic ;
  font-size: smaller }

p.label {
  white-space: nowrap }

p.rubric {
  font-weight: bold ;
  font-size: larger ;
  color: maroon ;
  text-align: center }

p.sidebar-title {
  font-family: sans-serif ;
  font-weight: bold ;
  font-size: larger }

p.sidebar-subtitle {
  font-family: sans-serif ;
  font-weight: bold }

p.topic-title {
  font-weight: bold }

pre.address {
  margin-bottom: 0 ;
  margin-top: 0 ;
  font-family: serif ;
  font-size: 100% }

pre.literal-block, pre.doctest-block {
  margin-left: 2em ;
  margin-right: 2em ;
  background-color: #eeeeee }

span.classifier {
  font-family: sans-serif ;
  font-style: oblique }

span.classifier-delimiter {
  font-family: sans-serif ;
  font-weight: bold }

span.interpreted {
  font-family: sans-serif }

span.option {
  white-space: nowrap }

span.pre {
  white-space: pre }

span.problematic {
  color: red }

span.section-subtitle {
  /* font-size relative to parent (h1..h6 element) */
  font-size: 80% }

table.citation {
  border-left: solid 1px gray;
  margin-left: 1px }

table.docinfo {
  margin: 2em 4em }

table.docutils {
  margin-top: 0.5em ;
  margin-bottom: 0.5em }

table.footnote {
  border-left: solid 1px black;
  margin-left: 1px }

table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
  padding-left: 0.5em ;
  padding-right: 0.5em ;
  vertical-align: top }

table.docutils th.field-name, table.docinfo th.docinfo-name {
  font-weight: bold ;
  text-align: left ;
  white-space: nowrap ;
  padding-left: 0 }

h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
  font-size: 100% }

tt.docutils {
  background-color: #eeeeee }

ul.auto-toc {
  list-style-type: none }

</style>
</head>
<body>
<div class="document" id="easypost-a-basic-cli-postfix-dovecot-administration-system">
<h1 class="title">Easypost; A basic CLI postfix/dovecot administration system</h1>
<p>Author: Jelle 'wires' Herold <tt class="docutils literal"><span class="pre">jelle</span> <span class="pre">{at}</span> <span class="pre">defekt</span> <span class="pre">{dot}</span> <span class="pre">nl</span></tt></p>
<div class="section">
<h1><a id="requirements" name="requirements">Requirements</a></h1>
<p>This is intended for Debian/Ubuntu based systems. Minimum requirements:</p>
<blockquote>
<ul class="simple">
<li>Dovecot</li>
<li>Postfix</li>
<li>Postgresql</li>
<li>Python-sqlobject (which again depends on psycopg</li>
<li>Python-configobj</li>
<li>APG automatic password generator</li>
</ul>
</blockquote>
<p><tt class="docutils literal"><span class="pre">sudo</span> <span class="pre">aptitude</span> <span class="pre">install</span> <span class="pre">postfix-pgsql</span> <span class="pre">dovecot-imapd</span> <span class="pre">python-sqlobject</span> <span class="pre">python-configobj</span> <span class="pre">python-psycopg2</span> <span class="pre">postgresql</span> <span class="pre">apg</span></tt></p>
<p><em>Note</em>: python-sqlobject seems to depend on python2.4, which I'm not running.
So, I suggest you install that using <tt class="docutils literal"><span class="pre">easy_install</span> <span class="pre">sqlobject</span></tt>, which is in
<tt class="docutils literal"><span class="pre">python-setuptools</span></tt>.</p>
</div>
<div class="section">
<h1><a id="setup" name="setup">Setup</a></h1>
<p>We shall be needing a password for the database user, so we generate a 12
character long password consisting of numeric, capital and lowercase characters.</p>
<p><tt class="docutils literal"><span class="pre">apg</span> <span class="pre">-M</span> <span class="pre">NCL</span> <span class="pre">-n1</span> <span class="pre">-m12</span> <span class="pre">-x12</span></tt></p>
<div class="section">
<h2><a id="postgresql" name="postgresql">Postgresql</a></h2>
<p>First, postgresql setup. We create a password protected user
with limited capabilities, called <tt class="docutils literal"><span class="pre">easypost</span></tt>. The password
is encrypted using MD5 (see <tt class="docutils literal"><span class="pre">man</span> <span class="pre">createuser</span></tt> for details).
Also, we create a database called <tt class="docutils literal"><span class="pre">easypost</span></tt> for this user.:</p>
<pre class="literal-block">
sudo -u postgres bash
createuser -DRESP easypost
createdb -O easypost easypost
exit
</pre>
<p>(you enter the password we generated earlier)</p>
<p>We are running postfix and postgresql on the same system. So
we first configure postgres to accept connections from user.
Add the following line to
<tt class="docutils literal"><span class="pre">/etc/postgresql/8.2/main/pg_hba.conf</span></tt>.:</p>
<pre class="literal-block">
local easypost easypost md5
host  easypost easypost 127.0.0.1/32 md5
</pre>
<p>(Make sure this is above the line that says <tt class="docutils literal"><span class="pre">local</span> <span class="pre">all</span> <span class="pre">all</span>
<span class="pre">ident</span> <span class="pre">sameuser</span></tt>. Also, the second line is not needed if there
is a line like <tt class="docutils literal"><span class="pre">host</span> <span class="pre">all</span> <span class="pre">all</span> <span class="pre">127.0.0.1/32</span> <span class="pre">md5</span></tt>.)</p>
<p>Now restart postgresql with <tt class="docutils literal"><span class="pre">/etc/init.d/postgresql-8.3</span> <span class="pre">restart</span></tt>.</p>
<p>That's it. You can test this (as any user) with::</p>
<pre class="literal-block">
psql easypost -U easypost
psql easypost -U easypost -l localhost
</pre>
<p>(This should ask for the passphrase).</p>
</div>
<div class="section">
<h2><a id="setup-the-system" name="setup-the-system">Setup the system.</a></h2>
<blockquote>
<ul class="simple">
<li>read configuration from /etc/easypost/config</li>
<li>if not found, read configuration from ./easypost.cfg</li>
<li>if not found, fail</li>
<li>connect to database and create tables</li>
<li>if not exists &lt;postfix_conf_dir&gt;, create it</li>
<li>write example postfix configuration files to this dir</li>
<li>if not exists &lt;dovecot_conf_dir&gt;, create it</li>
<li>write example dovecot configuration files to this dir</li>
</ul>
</blockquote>
<p><tt class="docutils literal"><span class="pre">easypost</span> <span class="pre">setup</span> <span class="pre">-p</span> <span class="pre">&lt;postfix_conf_dir&gt;</span> <span class="pre">-d</span> <span class="pre">&lt;dovecot_conf_dir&gt;</span></tt></p>
</div>
</div>
<div class="section">
<h1><a id="usage" name="usage">Usage</a></h1>
<div class="section">
<h2><a id="creating-users-and-email-adresses" name="creating-users-and-email-adresses">Creating users and email adresses</a></h2>
<p>First, create the user named &lt;username&gt; with the associated
primary email address.</p>
<p>If you specify --unix and a local UNIX user named &lt;username&gt;
exists, the mailbox will be owned by that user and placed
in that users homedir.</p>
<p>In the configuration file can be configured where this
mailbox should be placed, e.g. /var/www/&lt;domain&gt;/mail/&lt;user&gt;</p>
<p><tt class="docutils literal"><span class="pre">easypost</span> <span class="pre">create</span> <span class="pre">user</span> <span class="pre">&lt;username&gt;</span> <span class="pre">&lt;primaryEmailAddress&gt;</span> <span class="pre">[--unix]</span></tt></p>
<p><tt class="docutils literal"><span class="pre">easypost</span> <span class="pre">remove</span> <span class="pre">user</span> <span class="pre">&lt;username&gt;</span></tt></p>
<p>Add a email address to a user (likewise, remove).</p>
<p><tt class="docutils literal"><span class="pre">easypost</span> <span class="pre">user</span> <span class="pre">&lt;username&gt;</span> <span class="pre">add</span> <span class="pre">address</span> <span class="pre">&lt;address&gt;</span></tt></p>
<p><tt class="docutils literal"><span class="pre">easypost</span> <span class="pre">user</span> <span class="pre">&lt;username&gt;</span> <span class="pre">remove</span> <span class="pre">address</span> <span class="pre">&lt;address&gt;</span></tt></p>
</div>
<div class="section">
<h2><a id="password-changes" name="password-changes">Password changes</a></h2>
<p>(Re-)generate a random password for the specified user, and optionally email
this somewhere, including system informat (e.g. what mail server to use, etc)</p>
<p><tt class="docutils literal"><span class="pre">easypost</span> <span class="pre">user</span> <span class="pre">&lt;username&gt;</span> <span class="pre">generate-password</span> <span class="pre">[--mail-to</span> <span class="pre">&lt;email_address&gt;]</span></tt></p>
<p>Change the password interactively.</p>
<p><tt class="docutils literal"><span class="pre">easypost</span> <span class="pre">user</span> <span class="pre">&lt;username&gt;</span> <span class="pre">change-password</span></tt></p>
</div>
<div class="section">
<h2><a id="listing-database-contents" name="listing-database-contents">Listing database contents</a></h2>
<p>List all users. Optionally limit to all users at &lt;domain&gt; or
with email adress &lt;address&gt;.</p>
<p><tt class="docutils literal"><span class="pre">easypost</span> <span class="pre">list</span> <span class="pre">users</span> <span class="pre">[--domain</span> <span class="pre">&lt;domain&gt;]</span> <span class="pre">[--address</span> <span class="pre">&lt;address&gt;]</span></tt></p>
<p>Likewise, list all email adresses. Optionally for a domain or specific user.</p>
<p><tt class="docutils literal"><span class="pre">easypost</span> <span class="pre">list</span> <span class="pre">addresses</span> <span class="pre">[--domain</span> <span class="pre">&lt;domain&gt;]</span> <span class="pre">[--user</span> <span class="pre">&lt;username&gt;]</span></tt></p>
<p>List all domains (for a specific user).</p>
<p><tt class="docutils literal"><span class="pre">easypost</span> <span class="pre">list</span> <span class="pre">domains</span> <span class="pre">[--user</span> <span class="pre">&lt;username&gt;]</span></tt></p>
</div>
</div>
</div>
<div class="footer">
<hr class="footer" />
<a class="reference" href="easypost.rst">View document source</a>.
Generated on: 2008-10-08 12:41 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.

</div>
</body>
</html>
